<?php
	include("HTML_top.php");
	include("header.php");
?>

<h2>Popular Tags</h2>

<table border="0" cellspacing="0" cellpadding="10">
<tr>
	<td width="200"><b>Tag</b></td>
	<td width="200"><b>PushPins</b></td>
	<td width="200"><b>Unique CorkBoards</b></td>
</tr>

<?php

include("conn.php");
connectToDB();

$q = mysql_query("
SELECT `tag`, COUNT(*) as `PushPins`, COUNT(DISTINCT `email`, `title`) AS `Unique Corkboards`
FROM `pushpin_tags`
GROUP BY `tag`
ORDER BY COUNT(*) DESC
LIMIT 0, 5;
");

while ($r = mysql_fetch_array($q))
{
	echo '<tr>';
	
	echo '<td><a href="search.php?q='.urlencode($r['tag']).'">' . $r['tag'] . '</a></td>';
	echo '<td>' . $r['PushPins'] . '</td>';
	echo '<td>' . $r['Unique Corkboards'] . '</td>';
	
	echo '</tr>';
}

?>

</table>

<?php
	include("footer.php");
	include("HTML_bottom.php");
?>
